home *** CD-ROM | disk | FTP | other *** search
- <WIZSET LibraryDirectory = Trim(LibraryDirectory)>
- <WIZIF Right( LibraryDirectory, 1 ) EQ '\'>
- <WIZSET LibraryDirectory = Left( LibraryDirectory, Len(LibraryDirectory) - 1 )>
- </WIZIF>
-
- <!--- parameters --->
- <CFSET LibraryDirectory = "$${LibraryDirectory}">
- <WIZIF IsOverwriteEnabled
- ><CFSET IsOverwriteEnabled = "YES">
- <WIZELSE
- ><CFSET IsOverwriteEnabled = "NO">
- </WIZIF>
-
-
- <!--- upload file with unique name --->
- <CFFILE
- action="UPLOAD"
- fileField="UploadedFile"
- destination="#LibraryDirectory#\"
- nameConflict="MAKEUNIQUE"
- >
-
-
- <!--- new name of the uploaded file --->
- <CFIF Form.ServerFile is ''>
- <CFSET NewServerFile = File.ClientFile>
- <CFELSE>
- <CFSET NewServerFile = Form.ServerFile>
- </CFIF>
-
-
- <!--- check whether the new file name already exists in the directory --->
- <CFDIRECTORY
- name="CheckFile"
- action="LIST"
- directory="#LibraryDirectory#\"
- filter="#NewServerFile#"
- >
- <CFIF CheckFile.RecordCount is 0
- or File.ClientFile is File.ServerFile>
- <CFSET FileAlreadyExists = "NO">
- <CFELSE>
- <CFSET FileAlreadyExists = "YES">
- </CFIF>
-
-
- <HTML><HEAD>
- <TITLE>$${ApplicationName} - File Received</TITLE>
- </HEAD><BODY bgcolor="ffffff">
-
- <FONT size="+1">$${ApplicationName}</FONT> <BR>
-
- <!--- if file name already exists and overwrite is allowed delete file and throw an error --->
- <CFIF FileAlreadyExists and not IsOverwriteEnabled>
-
- <!--- delete file --->
- <CFSET TempFilePath = "#LibraryDirectory#\#File.ServerFile#">
- <CFFILE
- action="DELETE"
- file="#TempFilePath#"
- >
-
- <FONT size="+2" color="ff0000"><B>File Already Exists</B></FONT>
- <P>
- Press Back button and use different file name.
-
- <!--- ... else rename the file --->
- <CFELSE>
-
- <!--- rename file --->
- <CFSET SourceName = LibraryDirectory & '\' & File.ServerFile>
- <CFSET DestinationName = LibraryDirectory & '\' & NewServerFile>
- <CFFILE
- action="RENAME"
- source="#SourceName#"
- destination="#DestinationName#"
- >
-
- <FONT size="+2"><B>File Received</B></FONT>
- <P>
- File was successfully received.
- <P>
- [<A href="$${SafeApplicationName}_FileLibrary.cfm">Library</A>]
- </CFIF>
-
- </BODY></HTML>